﻿<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="dictsubject.aspx.cs" Inherits="Basic_dictsubject" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>学科字典</title>
    <link rel="stylesheet" type="text/css" href="../js/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../js/themes/icon.css"/>
	<link rel="stylesheet" type="text/css" href="../CSS/Style.css"/>
    <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
   	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script> 
    <script type="text/javascript">
      function operate(act){
      $("#note").text(""); 
      $("#sub").toggle(); 
      if(act=="add1"){
          $("#ddlSubject").css("display","none");
          $("#note1").css("display","none");
          $("#note2").css("display","inline");
          $("#note3").css("display","inline");
          $("#txtField1").css("display","inline");
          $("#txtField2").css("display","inline");
          $("#Button1").css("display","none");
          $("#Button2").css("display","inline");
          $("#Button3").css("display","none");
          $("#Button4").css("display","none");
         }
        else if(act=="delete"){
          $("#note1").css("display","inline");
          $("#note2").css("display","none");
          $("#note3").css("display","none");
          $("#ddlSubject").css("display","inline");
          $("#txtField1").css("display","none");
          $("#txtField2").css("display","none");
          $("#Button1").css("display","none");
          $("#Button2").css("display","none");
          $("#Button3").css("display","inline");
          $("#Button4").css("display","none");
         }
        else if(act=="modify"){
          $("#note1").css("display","inline");
          $("#note2").css("display","inline");
          $("#note3").css("display","none");
          $("#ddlSubject").css("display","inline");
          $("#txtField1").css("display","inline");
          $("#txtField2").css("display","none");
          $("#Button1").css("display","none");
          $("#Button2").css("display","none");
          $("#Button3").css("display","none");
          $("#Button4").css("display","inline");
         } 
         else if(act=="add2"){
          $("#note1").css("display","none");
          $("#note2").css("display","none");
          $("#note3").css("display","inline");
          $("#ddlSubject").css("display","inline");
          $("#txtField1").css("display","none");
          $("#txtField2").css("display","inline");
          $("#Button1").css("display","inline");
          $("#Button2").css("display","none");
          $("#Button3").css("display","none");
          $("#Button4").css("display","none");
         }  
     }  
     function cancel(){
     $("#sub").css("display","none");
     }
     function check(tar){
        if(tar=="add2"){
          var subject=$("#ddlSubject").val();
          var str=$.trim($("#txtField2").val()); 
          if(subject=="0"){
              $("#note").text("您未选择学科门！");
              return false;} 
          else if(str==""){
              $("#note").text("一级类名不能为空！");
              return false; }
        }
        if(tar=="add1"){
          var str1=$.trim($("#txtField1").val()); 
          var str2=$.trim($("#txtField2").val()); 
          if(str1==""){
              $("#note").text("学科门不能为空！");
              return false;}
          else if(str2==""){
              $("#note").text("一级类名不能为空！");
              return false;} 
        }
        if(tar=="delete"){
          var subject=$("#ddlSubject").val();
          if(subject=="0"){
              $("#note").text("您未选择要删除的学科门！");
              return false;} 
          else
              return confirm("删除此学科将删除其下所有一级类，您确定删除？");
        }
        if(tar=="modify"){
          var str=$.trim($("#txtField1").val()); 
          var subject=$("#ddlSubject").val();
          if(subject=="0"){
              $("#note").text("您未选择要要修改的学科门！");
              return false;} 
          if(str==""){
              $("#note").text("学科门名不能为空！");
              return false; }
        }
     }
   </script> 
</head>
<body>
    <form id="form1" runat="server">
   	<div style="background:#efefef;">
         <a href="javascript:operate('add2')" class="easyui-linkbutton" plain="true" icon="icon-add">增加一级类</a>    	
         <a href="javascript:operate('add1')" class="easyui-linkbutton" plain="true" icon="icon-add">增加学科门</a>
         <a href="javascript:operate('delete')" class="easyui-linkbutton" plain="true" icon="icon-remove">删除学科门</a> 
         <a href="javascript:operate('modify')" class="easyui-linkbutton" plain="true" icon="icon-add">修改学科门</a>
	</div>	
	        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
           <div id="sub" style="background:#efefef; display:none;"><span id="note1">请选择学科门类别：</span>
               <asp:DropDownList ID="ddlSubject" runat="server">
               </asp:DropDownList>
              <span id="note2">请输入学科门名：</span> 
               <asp:TextBox ID="txtField1" runat="server" Width="80px"></asp:TextBox>
              <span id="note3">请输入学科一级类名：</span> 
               <asp:TextBox ID="txtField2" runat="server"></asp:TextBox>
               <asp:Button ID="Button1" runat="server" Text="添加" OnClientClick="return check('add2');" OnClick="btnSubmit_Click" CssClass="btn-dy-blue" />
               <asp:Button ID="Button2" runat="server" Text="添加" OnClientClick="return check('add1');" OnClick="Button2_Click" CssClass="btn-dy-blue" />
               <asp:Button ID="Button3" runat="server" Text="删除" OnClientClick="return check('delete');" OnClick="Button3_Click" CssClass="btn-dy-blue" />
               <asp:Button ID="Button4" runat="server" Text="提交" OnClientClick="return check('modify');" OnClick="Button4_Click" CssClass="btn-dy-blue" />
               <input id="btncancel" type="button" value="放弃" onclick="cancel()" class="btn-dy-blue"/><span id="note" style="color:Red;"></span></div>
            </ContentTemplate>
        </asp:UpdatePanel>
 <div style="background: #FFFCC9;border: 1px solid #FFD667;"><img src="../Images/Warning.png" alt="提示" />
    <span>提示：点击以下的删除/编辑按钮只能删除/编辑学科一级类，若想删除/编辑学科门请点击删除/编辑学科门。</span> </div> 
  <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server" CssClass="gvStyle" AlternatingRowStyle-CssClass="alt" 
                PagerStyle-CssClass="pgr" OnRowCommand="GridView1_RowCommand" AutoGenerateColumns="False" 
                Width="100%" Font-Bold="False" EmptyDataText="暂时没有任何院系数据！" OnRowCancelingEdit="GridView1_RowCancelingEdit" 
                EnableTheming="False" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" 
                DataKeyNames="id">
                    <Columns>
                        <asp:TemplateField HeaderText="序号">
                            <ItemTemplate> 
                                 <%# (this.AspNetPager1.CurrentPageIndex - 1) * this.AspNetPager1.PageSize + Container.DataItemIndex + 1%>
                            </ItemTemplate> 
                                </asp:TemplateField>
                        <asp:BoundField DataField="subject1" HeaderText="学科门" ReadOnly="True" />
                        <asp:BoundField DataField="subject2" HeaderText="学科一级类" />
                        <asp:TemplateField HeaderText="状态">
                            <ItemTemplate>
                                <asp:Label ID="labStatus" runat="server" Text='<%# (bool)Eval( "isuse")?"已启用":"已禁用" %>'></asp:Label>&nbsp;<asp:ImageButton
                                    ID="IbtnUnenable" runat="server" CommandArgument="<%# Container.DataItemIndex %>"
                                    Enabled='<%# (bool)Eval("isuse") %>' ImageUrl="~/js/themes/icons/no.png" ToolTip="禁用" CommandName="close" />
                                <asp:ImageButton ID="IbtnEnable" runat="server" CommandArgument="<%# Container.DataItemIndex %>"
                                    Enabled='<%#!(bool)Eval("isuse") %>' ImageUrl="~/js/themes/icons/ok.png" ToolTip="启用" CommandName="open" />
                            </ItemTemplate>
                            <ItemStyle Width="130px" />
                        </asp:TemplateField>
                        <asp:CommandField ShowEditButton="True" ButtonType="Image" CancelImageUrl="~/js/themes/icons/undo.png" EditImageUrl="~/js/themes/icons/pencil.png" UpdateImageUrl="~/js/themes/icons/filesave.png" HeaderText="操作" >
                            <ItemStyle Width="80px" />
                        </asp:CommandField>
                        <asp:TemplateField HeaderText="删除">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageButton1" runat="server" CommandName="delsubject" ImageUrl="~/js/themes/icons/cancel.png" CommandArgument="<%# Container.DataItemIndex %>" OnClientClick='return confirm("您确定要删除此学科？");' />&nbsp;
                            </ItemTemplate>
                            <ItemStyle Width="30px" />
                        </asp:TemplateField>
                    </Columns>
                         <PagerStyle CssClass="pgr" />
                     <AlternatingRowStyle CssClass="alt" />
                </asp:GridView>
                <webdiyer:aspnetpager id="AspNetPager1" runat="server"
                        HorizontalAlign="Right" LastPageText="末页" NextPageText="下一页" 
                        PageIndexBoxType="TextBox" PageSize="15" PrevPageText="上一页" ShowCustomInfoSection="Left"
                        ShowPageIndexBox="Always" Width="100%" CustomInfoHTML="共<font color=blue><b>%RecordCount%</b></font>条数据 每页：<font color=blue><b>%PageSize%</b></font> 条 共<font color=blue><b>%PageCount%</b></font>页 当前页：<font color=red><b>%CurrentPageIndex%/%PageCount%</b></font>" OnPageChanged="AspNetPager1_PageChanged" CustomInfoSectionWidth="50%" FirstPageText="首页" AlwaysShow="True" CustomInfoTextAlign="Left">
                </webdiyer:aspnetpager>
            </ContentTemplate>
        </asp:UpdatePanel></div> 
    </form>
</body>
</html>
